#ifndef LTGSQL_TYPES_H
#define LTGSQL_TYPES_H

#include "common.h"

// 数据类型
typedef enum {
    LTGSQL_TYPE_INT32,
    LTGSQL_TYPE_INT64,
    LTGSQL_TYPE_FLOAT,
    LTGSQL_TYPE_DOUBLE,
    LTGSQL_TYPE_STRING,
    LTGSQL_TYPE_BOOL,
    LTGSQL_TYPE_TIMESTAMP,
    LTGSQL_TYPE_BINARY,
    LTGSQL_TYPE_DECIMAL,
    LTGSQL_TYPE_JSON,
    LTGSQL_TYPE_GRAPH_NODE,
    LTGSQL_TYPE_GRAPH_EDGE
} ltgsql_data_type;

/**
 * 值结构
 */
typedef struct {
    ltgsql_data_type type;
    union {
        int32_t int32_val;
        int64_t int64_val;
        float float_val;
        double double_val;
        char* string_val;
        ltgsql_bool bool_val;
        time_t timestamp_val;
        struct {
            void* data;
            size_t size;
        } binary_val;
        struct {
            int64_t value;
            int32_t scale;
        } decimal_val;
    };
    ltgsql_bool is_null;
} ltgsql_value;

// 表元数据
typedef struct {
    char* name;
    ltgsql_data_type* column_types;
    char** column_names;
    size_t* column_sizes;
    size_t column_count;
    size_t row_count;
    size_t table_size;
} ltgsql_table_metadata;

// 查询结果集
typedef struct {
    ltgsql_value** rows;
    size_t row_count;
    size_t column_count;
    char** column_names;
} ltgsql_result_set;

#endif // LTGSQL_TYPES_H